import { IsNotEmpty, IsEnum, Min, IsDate, IsOptional, IsNumberString } from 'class-validator';
import { BaseEntity } from "src/baseEntity";
import { System } from 'src/system/system.entity';
import { UserSys } from 'src/user/userSys.entity';
import { Column, Entity, ManyToOne } from "typeorm";
export enum DormitoryUsage {
    男生宿舍 = "男生宿舍",
    女生宿舍 = "女生宿舍",
    办公 = "办公",
    仓库 = "仓库"
}
@Entity("dormitory")
export class Dormitory extends BaseEntity {
    @ManyToOne(() => System)
    system: System

    @ManyToOne(() => UserSys)
    user: UserSys

    @Column()
    @IsNotEmpty({ message: '地址不能为空' })
    address: string;

    @Column({ type: "enum", enum: DormitoryUsage })
    @IsEnum(DormitoryUsage, { message: '用途必须是有效的选项' })
    @IsNotEmpty({ message: '用途不能为空' })
    usage: DormitoryUsage;

    @Column()
    @IsNotEmpty({ message: '房东姓名不能为空' })
    landlordName: string;

    @Column()
    @IsNotEmpty({ message: '房东电话不能为空' })
    landlordPhone: string;

    @Column()
    @IsNumberString({}, { message: '房租必须是有效的数字' })
    @IsNotEmpty({ message: '房租不能为空' })
    rent: number;

    @Column({ type: "timestamp", nullable: true })
    @IsOptional()
    rentPaymentDate: Date;

    @Column({ type: "timestamp", nullable: true })
    @IsOptional()
    rentDueDate: Date;

    @Column()
    @IsNumberString({}, { message: '物业费必须是有效的数字' })
    @IsNotEmpty({ message: '物业费不能为空' })
    propertyFee: number;

    @Column({ type: "timestamp", nullable: true })
    @IsOptional()
    propertyPaymentDate: Date;

    @Column({ type: "timestamp", nullable: true })
    @IsOptional()
    propertyDueDate: Date;

    @Column()
    @IsNotEmpty({ message: '电卡号不能为空' })
    electricCard: string;

    @Column()
    @IsNotEmpty({ message: '水表号不能为空' })
    waterMeter: string;

    @Column()
    @IsNotEmpty({ message: '燃气号不能为空' })
    gasMeter: string;

    @Column()
    @IsNumberString({}, { message: '容纳人数必须是整数' })
    capacity: number;

    @Column()
    @IsNumberString({}, { message: '已用人数必须是整数' })
    occupancy: number;
}